const http = require('../../utils/http.js');
Page({
  submitFile: function(){
    wx.chooseMessageFile({
      count: 1,
      type: 'all',
      success: (chooseRes)=>{
        const tempFile = chooseRes.tempFiles[0]; // 选择的第一个文件
        console.log(tempFile);
        console.log('文件路径:', tempFile.path);
        console.log('文件名称:', tempFile.name);
        console.log('文件大小:', tempFile.size);

        const storedUserInfo = wx.getStorageSync('userInfo');
        const userName = storedUserInfo.userName; // 获取当前用户的学号
        console.log(userName);
        const data = {
          files:[tempFile],
          username : userName,
          range:0
        }

        http.uploadFile(data,tempFile.path).then(res =>{
          console.log(res);
        }).catch(err => {
          console.log("1")
          console.log(err);
        })
      }
    })
  },

  showFile: function(){
    wx.navigateTo({
      url: '/pages/downloadFile/downloadFile',
    })
  }

});
